<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" style="overflow: hidden;padding: 10px;">
			<div class="edit-btn" style="height:auto;margin-right:0px">
				<div>
					<a href="javascript:void(0);" class="easyui-linkbutton function-btn" iconcls="icon-save" plain="true" >保存</a>
					<a href="javascript:void(0);" class="easyui-linkbutton function-btn" iconcls="icon-cancel" plain="true" >取消</a>	
				</div>
			</div>
  			<form  class="main-form" method="post">	
			 	 	
		    <fieldset>								
					<input name="id" id="id"  type="hidden"/>
					<input name="parentName" id="parentName"  type="hidden"/>
					<input name="created" id="created"  type="hidden"/>					
					<input name="creater" id="creater"  type="hidden"/>
					<input name="status" id="status"  type="hidden"/>					
					<input name="leader_ids" id="leader_ids"  type="hidden"/>
					<input name="extend" id="extend" type="hidden"/>
					 <table>
						 <tr>
						    <th>部门名称</th>
							<td><input name="name" id="name"  class="easyui-textbox" type="text" data-options="disabled:true,editable:false"/></td>
							<th>组织编码</th>
							<td><input name="identify" id="identify" type="text"  class="easyui-textbox" data-options="disabled:true,editable:false"/></td>
						 </tr>
						 <tr>
						    <th>部门编码</th>
							<td><input name="bizcode" id="bizcode" type="text" class="easyui-textbox" data-options="disabled:true,editable:false"/></td>
							<th>完整编码</th>
							<td><input id="fullBizcode" name="fullBizcode" type="text" class="easyui-textbox " data-options="disabled:true,editable:false"/></td>
						 </tr>
						 <tr>
						 	<th>上层组织</th>
							<td><input id="parentName" name="parentName" type="text" class="easyui-textbox easyui-validatebox" data-options="disabled:true,editable:false"/></td>
						    <th>英文名称</th>
							<td><input id="eName" name="eName" type="text" class="easyui-textbox easyui-validatebox"/></td>
							
						 </tr>
						 <tr>
						    <th>部门全称</th>
							<td><input name="longName" id="longName" type="text" class="easyui-textbox" /></td>
							<th>部门简称</th>
							<td><input id="shortName" name="shortName" type="text" class="easyui-textbox easyui-validatebox"/></td>
						 </tr>
						 
						  <tr>
						  	<th>主管领导</th>
							<td><input id="leader_names" name="leader_names" buttonText="选择" type="text" class="easyui-textbox"/></td>					    
							<th>组织图标</th>
							<td><input id="iconCls" name="iconCls" type="text" class="easyui-textbox"/></td>
						 </tr>
						 <tr>
						    <th>电话</th>
							<td><input id="tel" name="tel" type="text" class="easyui-textbox easyui-validatebox"/></td>
							<th>默认站点</th>
							<td><input id="siteName" name="siteName" type="text" class="easyui-textbox easyui-validatebox"/></td>
						 </tr>
						 <tr>
							<th>描述</th>
							<td colspan="3"><textarea class="easyui-textbox" name="description"  style="width: 420px;height: 50px;"></textarea></td>
						</tr>
					 </table>
				</fieldset>
		</form>
			
			
		
		
	</div>
</div>
<script>

requirejs(['domReady!'],function(doc){
	
	var rootid = 'panel-department'
	var window_id = 'department-extend-win'
	
	
	$('#'+window_id+' #extend').val(true)
	
	var $dg=$('#'+rootid +' table.dg-list')
	if($dg.length>0){
		
		require(['sysmanMain','deptUserSelect','formServ','msgServ','btnServ'],
			function(main,deptUserSelect,formServ,msgServ,btnServ){
			
			var record = $dg.datagrid('getSelected')
			if(record && record.id){
				$.ajax({
					url:'/'+main.getRootPath()+'/department/query/getExtendOne.action',
					data:{id:record.id},
					success:function(data){
						record.leader_ids = data.leader_ids;
						record.leader_names = data.leader_names;
						$('#'+window_id + ' form.main-form').form('clear');
						$('#'+window_id + ' form.main-form').form('load',record);
					}
				})
			}
		
			
			
			var el = $('#department-extend-win #leader_names')
			console.log('el.length:' + el.length)
			el.textbox({
				onClickButton:function(data){								
					deptUserSelect.openPage({
						userids:window_id+' #leader_ids',
						usernames:window_id+' #leader_names'					
					})								
				}
			})	
			
			//定义响应方法
			var func={
				"保存":function(e){
					var $form = $('#'+window_id + ' form.main-form')
					var data = formServ.getDataStr({form:$form})
					$.ajax({
						url:'/'+main.getRootPath()+'/department/saveExtend.action',
						data:data,
						contentType : 'appliction/json;charset=utf-8',
						type :'post',
						success:function(data){
							$form.form('load',data),
							msgServ.Msgslide('保存操作成功');
							if(e && e.currentTarget){
								$(e.currentTarget).linkbutton('enable');
							}
						},
						error:function(){
							msgServ.Msgslide('保存操作失败。。。');	
							if(e && e.currentTarget){
								$(e.currentTarget).linkbutton('enable');
							}						
						}
					})
				}
				,
				"取消" : function(e) {
					$('#'+window_id).window('close');
				}
				,
				function_btn_listenner : function(e) {

					btnServ.applyButton({buttonEvt:e,buttonConfig:func})
		
				}
			}
			var btn = $('#'+window_id + ' a.function-btn')
			if(btn.length>0){
				btn.unbind('click');
				btn.bind('click',func.function_btn_listenner)
			}	
		})
	}
});	

</script>